// Fill out your copyright notice in the Description page of Project Settings.


#include "StateMachine/PlayerState/JumpState.h"

#include "Core/Character2D.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "StateMachine/StateMachine.h"
#include "StateMachine/PlayerState/FallState.h"


void UJumpState::Enter()
{
	Super::Enter();
	Character->PlayAnimation(FName("Jump"));
	Character->Jump();
}

void UJumpState::Exit()
{
	Super::Exit();
}

void UJumpState::Tick(float Delta)
{
	Super::Tick(Delta);
	
	const FVector Velocity = Character->GetVelocity();
	if (MovementComponent->IsFalling() && Velocity.Z < -0.1f)
	{
		StateMachine->SwitchState(UFallState::StaticClass());
	}
}

void UJumpState::InputSignal(EInputSignal Signal, const FInputActionValue& Value)
{
	Super::InputSignal(Signal, Value);
}
